/*
 * @Author: your name
 * @Date: 2022-01-24 11:27:41
 * @LastEditTime: 2022-01-24 14:41:38
 * @LastEditors: LAPTOP-L472H14P
 * @Description: In User Settings Edit
 * @FilePath: \react_front_engineer\src\NodeJs\express\06自定义中间间.js
 */
const express = require('express')
const app = express()
const handleJson = (req, res, next) => {
  let bodyParams = ''
  req.on('data', (data) => {
    // JSON.parse(data)
    console.log(data);
    bodyParams += data
  })
  req.on('end', () => {
    console.log(' in the end' , bodyParams )
    req.acr = bodyParams
    next()
  })
  console.log(2222)
}
app.use(handleJson)
app.post('/userinfo', (req, res) => {
  console.log(req.acr)
  res.send(req.acr)
})
app.listen('3000', () => {
  console.log('serve is running')
})
